package com.jhc.drone.communication.hook;


import com.jhc.drone.communication.network.router.TcpRouter;
import com.jhc.drone.communication.network.router.UdpRouter;
import com.jhc.drone.communication.properties.ProtocolProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

/**
 * @author lcp
 * @date 2025年01月2025/1/20 16:02
 * @describe
 */
@Component
@RequiredArgsConstructor
public class RouterHook implements InitializingBean {

    private final ProtocolProperties protocolProperties;

    @Override
    public void afterPropertiesSet() {
        if (protocolProperties.openRouter) {
            switch (protocolProperties.protocol) {
                case TCP:
                    TcpRouter.start(protocolProperties);
                    break;
                case UDP:
                    UdpRouter.start(protocolProperties);
                    break;
                case MQTT:

                    break;
                default:
                    break;
            }
        }
    }

}
